Set(CTEST_SOURCE_DIRECTORY $ENV{VC_SOURCEDIR})
Set(CTEST_BINARY_DIRECTORY $ENV{VC_BUILDDIR})
Set(CTEST_SITE $ENV{SITE})
Set(CTEST_BUILD_NAME $ENV{LABEL})
Set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
Set(CTEST_PROJECT_NAME "VC")
Set(CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE TRUE)

include(CTestCustom.cmake)

Set(CTEST_CONFIGURE_COMMAND "${CMAKE_EXECUTABLE_NAME} ${CTEST_SOURCE_DIRECTORY} -DCMAKE_BUILD_TYPE=Release -DBUILD_BENCHMARKS=TRUE -DBUILD_EXAMPLES=TRUE")
Set(BUILD_COMMAND "make")
Set(CTEST_BUILD_COMMAND "${BUILD_COMMAND} -j$ENV{number_of_processors} -k")

if($ENV{ctest_model} STREQUAL "Continuous")
   while(${CTEST_ELAPSED_TIME} LESS 64800)
      set(START_TIME ${CTEST_ELAPSED_TIME})
      CTEST_START (Continuous)
      CTEST_UPDATE (SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res)
      if(res GREATER 0)
         CTEST_CONFIGURE (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
         if(res EQUAL 0)
            CTEST_BUILD (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
            if(res EQUAL 0)
               CTEST_TEST (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
            endif(res EQUAL 0)
         endif(res EQUAL 0)
         CTEST_SUBMIT (RETURN_VALUE res)
      endif(res GREATER 0)
      ctest_sleep(${START_TIME} 1200 ${CTEST_ELAPSED_TIME})
   endwhile()
else($ENV{ctest_model} STREQUAL "Continuous")
   CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY})
   CTEST_START ($ENV{ctest_model})
   if(NOT $ENV{ctest_model} STREQUAL "Experimental")
      CTEST_UPDATE (SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res)
   endif(NOT $ENV{ctest_model} STREQUAL "Experimental")
   CTEST_CONFIGURE (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
   CTEST_BUILD (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
   CTEST_TEST (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
   CTEST_SUBMIT (RETURN_VALUE res)
endif($ENV{ctest_model} STREQUAL "Continuous")
